#include "wx/confbase.h"
#include "wx/fileconf.h" 
#include "wxmudtextctrl.h"
#include "wxmudcommandline.h"
#include "globals.h"
#include <wx/log.h>
#define CMD_UP 0
#define CMD_DOWN 1
#define CMD_ADD 2
wxFileConfig * pConfig;
bool mudConnected = false;
bool doEcho = true;
telnet_t myTelnet_t;
wxMudTextCtrlArray mudTextWindows;

wxString gaugeString = wxEmptyString;
wxString gaugePattern = wxEmptyString;

wxMudCommandLine* commandLine = NULL;
void displayOutput(const char* buffer, int size){
    int i = 0;
    //iterate through each registered window
    while (i < mudTextWindows.GetCount()){
    //should append unprocessed to buffer first etc
    
    (mudTextWindows[i])->ProcessText(wxString(buffer, wxConvUTF8, size));
    i++;
    }
}

void displayOutput(wxString buffer){
    int i = 0;
    //iterate through each registered window
    while (i < mudTextWindows.GetCount()){
    (mudTextWindows[i])->ProcessText(buffer);
    i++;
    }
}

void setDefaultFont(wxTextAttr newDefaultStyle){
    int i = 0;
    //iterate through each registered window
    
    while (i < mudTextWindows.GetCount()){
    wxLogDebug(wxT("setting style for window %i"),i);
    (mudTextWindows[i])->SetDefaultStyle(newDefaultStyle);
    i++;
    }

}

void setBackgroundColour(wxColour newDefaultBackground){

    int i = 0;
    //iterate through each registered window
    
    while (i < mudTextWindows.GetCount()){
    (mudTextWindows[i])->SetBackgroundColour(newDefaultBackground);
    i++;
    }

}